package com.bowei.vo;

import com.github.pagehelper.PageInfo;

import java.util.List;

/**
 * 返回结果的统一封装：将所有可能返回的类型都写在这里
 */

public class ResultVo <T>{
    private PageInfo<T> pageInfo;//返回的是分页对象
    private List<T>list; //返回的是list
    private T obj; //返回的是单个对象/字符串等，取决于T的类型咯
    private Integer code=200; //状态码，默认200
    private String  msg="ok"; //成功/失败信息

    public ResultVo(PageInfo<T> pageInfo) { //只返回分页对象
        this.pageInfo = pageInfo;
    }

    public ResultVo(List<T> list) {  //只返回list
        this.list = list;
    }

    public ResultVo(Integer code, String msg) {//当操作失败，修改状态码和msg
        this.code = code;
        this.msg = msg;
    }

    public ResultVo(T obj) {
        this.obj = obj;
    }

    public ResultVo() { }

    public PageInfo<T> getPageInfo() {
        return pageInfo;
    }

    public void setPageInfo(PageInfo<T> pageInfo) {
        this.pageInfo = pageInfo;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public T getObj() {
        return obj;
    }

    public void setObj(T obj) {
        this.obj = obj;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "ResultVo{" +
                "pageInfo=" + pageInfo +
                ", list=" + list +
                ", obj=" + obj +
                ", code=" + code +
                ", msg='" + msg + '\'' +
                '}';
    }
}
